﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace L4View.BusinessModel
{
    using Infrastructure;

    public class NotifyMessageCollection : MessageCollection, ILogCollection
    {
        public event IncomingMessagesDelegete IncomingMessages;

        public override void Transfer(bool stop)
        {
            base.Transfer(stop);

            if (stop)
                RaiseIncomingMessagesEvent();
        }

        public ICollection<ILogMessage> LogMessages
        {
            get { return this.GetMessages().Cast<ILogMessage>().ToList(); }
        }

        private void RaiseIncomingMessagesEvent()
        {
            var notify = IncomingMessages;

            if (notify != null)
                notify();
        }
    }
}
